<?php

class block_accessibility extends block_base {

	function init() {
		global $COURSE;
		$this->title = get_string('accessibility','block_accessibility');
		$this->course = $COURSE;
		$this->version = 2010070600;
	}
	
	function get_content() {
		global $COURSE;
		if($this->content) {
			return $this->content;
		}
		$results = get_records('accessibility_test_results', 'course_id', $COURSE->id);
		$totals = array('number_severe' => 0, 'number_moderate' => 0, 'number_suggestion' => 0);
		foreach($results as $result) {
			foreach($totals as $k => $value) {
				$totals[$k] += $result->{$k};
			}
		}	
		$this->content = new stdClass();
		$this->content->text = '<ul>';
		$this->content->text .= '<li><strong>Severe</strong>: '. $totals['number_severe'] .'</li>';
		$this->content->text .= '<li><strong>Moderate</strong>: '. $totals['number_moderate'] .'</li>';
		$this->content->text .= '<li><strong>Suggestions</strong>: '. $totals['number_suggestion'] .'</li></ul>';
		$this->content->footer =  '<a href="'.$CFG->wwwroot.'/blocks/accessibility/course_report?id='.$COURSE->id.'">'.get_string('accessibility','block_accessibility').'</a>';;
		return $this->content;
	}
}